package com.vidyu.businesslayer.businessentities;

import com.vidyu.businesslayer.businesscomponents.Constants;
import javax.persistence.*;
import java.io.Serializable;

/**
 * Created by IntelliJ IDEA.
 * User: eyalsa
 * Date: 28/02/12
 * Time: 14:35
 * MonitorEvent represent events in the monitor system
 */

@Entity
@Table(name = "monitor_events")
public class MonitorEvent implements Serializable {
    private static final long serialVersionUID = -9199325180704715433L;
    private long id;
    private long time;
    private String serverId;
    private String module;
    private String text;
    private String className;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "monitor_event_id", nullable = false, length = 11)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getServerId() {
        return serverId;
    }

    public void setServerId(String serverId) {
        this.serverId = serverId;
    }

    public String getModule() {
        return module;
    }

    public void setModule(String module) {
        this.module = module;
    }

    @Column(length = 1028)
    public String getText() {
        return text;
    }

    public void setText(String text) {
        if (text != null) {
            if (text.length() > Constants.LONG_DB_STRING_LENGTH) {
                this.text = text.substring(0, Constants.LONG_DB_STRING_LENGTH);
            } else {
                this.text = text;
            }
        }
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }
}
